import Taro, { useEffect, useRouter, useState } from '@tarojs/taro';
import { View, Text, RichText } from '@tarojs/components';
import './index.less';
import NavBar from '../../../../components/navBar';

const TodayDetail = () => {
  const [params, setParams] = useState<any>();
  // const router = useRouter();
  useEffect(() => {
    Taro.getStorage({
      key: 'todays',
      success: res => {
        const result = JSON.parse(res.data);
        setParams(result);
      },
    });
    // const result = JSON.parse(router.params.data);
    // console.log(result);
  }, []);
  return (
    <View>
      {process.env.TARO_ENV === 'h5' ? <NavBar title={params ? params.src : ''} /> : null}
      <View className="container">
        <Text className="title">{params ? params.title : ''}</Text>
        {params ? <RichText className="content" nodes={params.content} /> : null}
      </View>
    </View>
  );
};

TodayDetail.config = {
  navigationBarTitleText: '详情',
};

export default TodayDetail;
